package com.bvgol.examples.swagger2.controller;

import com.alibaba.fastjson.JSONObject;
import com.bvgol.examples.swagger2.entity.TestEntity;
import com.bvgol.examples.swagger2.entity.TestEntity2;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;

@RestController
@Api(description = "why work to controller ")
@RequestMapping("/swagger/dome")
public class SwaggerDemoController {

    @ApiOperation(value = "swagger2示例接口描述1", httpMethod = "POST",
            notes = "这里是notes信息", response = TestEntity.class)
    @PostMapping("/list")
    public TestEntity listTest(@RequestBody TestEntity testEntity) {
        return testEntity;
    }

    @PostMapping("/list2")
    public String listTest2(@ApiParam(name = "name", value = "value",
            allowableValues = "test2", example = "小王", required = true) String name) {
        return name + ", hello";
    }

    @ApiOperation(value = "swagger2示例接口描述3", httpMethod = "POST",
            notes = "这里是notes3信息", response = JSONObject.class)
    @PostMapping("/list3")
    public JSONObject listTest3(@RequestParam TestEntity testEntity, @RequestParam TestEntity2 testEntity2) {
        JSONObject jo = new JSONObject();
        jo.put("TestEntity",testEntity);
        jo.put("TestEntity2",testEntity2);
        return jo;
    }


    @ApiOperation(value = "swagger2示例接口描述3", httpMethod = "GET",
            notes = "这里是notes4信息", response = JSONObject.class)
    @GetMapping("/list4")
    public JSONObject listTest4(@RequestParam TestEntity testEntity, @RequestParam TestEntity2 testEntity2) {
        JSONObject jo = new JSONObject();
        jo.put("TestEntity",testEntity);
        jo.put("TestEntity2",testEntity2);
        return jo;
    }

    @ApiOperation(value = "swagger2示例接口描述3", httpMethod = "GET",
            notes = "这里是notes5信息", response = JSONObject.class)
    @GetMapping("/list5")
    public TestEntity listTest5(@RequestParam("") TestEntity testEntity) {
        return testEntity;
    }


    @ApiOperation(value = "swagger2示例接口描述3", httpMethod = "POST",
            notes = "这里是notes6信息", response = JSONObject.class)
    @PostMapping("/list6")
    public TestEntity listTest6(@RequestParam String RequestParam, @RequestBody TestEntity testEntity) {

        return testEntity;
    }

    //localhost:10006/swagger-ui.html

    //this api only have /list
}
